package com.qzuser.sendmessagebasic.demo;

import com.qzuser.sendmessagebasic.client.Channel;
import com.qzuser.sendmessagebasic.client.Connection;
import com.qzuser.sendmessagebasic.client.ConnectionFactory;
import com.qzuser.sendmessagebasic.common.exception.ToolException;
import com.qzuser.sendmessagebasic.common.tool.BinaryTool;
import com.qzuser.sendmessagebasic.server.exchange.ExchangeType;

public class Producer {
    public static void main(String[] args) throws ToolException {
        ConnectionFactory cf = new ConnectionFactory();
        cf.setHost("127.0.0.1");
        cf.setPort(9999);
        Connection connection = cf.createConnection();
        Channel channel = connection.createChannel();
        channel.exchangeDeclare("exchange", ExchangeType.DIRECT, false, false, null);
        channel.queueDeclare("queue", false, false, false, null);
        for (int i = 0; i < 10; i++) {
            channel.basicPublish("exchange", "queue", null, ("Hello World" + i).getBytes());
        }
        channel.close();
        connection.close();
    }
}
